package com.thesis.unittest;

import static org.junit.Assert.*;

import org.junit.AfterClass;
import org.junit.Test;

import com.thesis.algorithm.Sequence;
import com.thesis.algorithm.SequenceElement;
import com.thesis.algorithm.SequenceMatching;

public class SequenceTest {

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Test
	public void testRefineSequence() {
		//fail("Not yet implemented");
		
		Sequence train = new Sequence();
		train.add(new SequenceElement((char)1, (char)100, (char)2, (char)10));
		train.add(new SequenceElement((char)1, (char)100, (char)2, (char)10));
		train.add(new SequenceElement((char)1, (char)100, (char)2, (char)10));
		train = train.refineSequence();
		assertEquals(train.size(), 1);
		assertEquals(train.get(0).Observation, 1);
		assertEquals(train.get(0).State, 100);
		assertEquals(train.get(0).Lac, 2);
		assertEquals(train.get(0).Repetition, 30);
		
		
		
		train = new Sequence();
		train.add(new SequenceElement((char)1, (char)100, (char)2, (char)10));
		train.add(new SequenceElement((char)1, (char)100, (char)2, (char)10));
		train.add(new SequenceElement((char)1, (char)100, (char)3, (char)10));
		train = train.refineSequence();
		assertEquals(train.size(), 2);
		assertEquals(train.get(0).Observation, 1);
		assertEquals(train.get(0).State, 100);
		assertEquals(train.get(0).Lac, 2);
		assertEquals(train.get(0).Repetition, 20);
		
		assertEquals(train.get(1).Observation, 1);
		assertEquals(train.get(1).State, 100);
		assertEquals(train.get(1).Lac, 3);
		assertEquals(train.get(1).Repetition, 10);
		
		
		
		train = new Sequence();
		train.add(new SequenceElement((char)1, (char)100, (char)50, (char)10));
		
		train.add(new SequenceElement((char)1, (char)101, (char)50, (char)10));
		train.add(new SequenceElement((char)1, (char)101, (char)50, (char)10));
		
		train.add(new SequenceElement((char)1, (char)101, (char)51, (char)10));
		train.add(new SequenceElement((char)1, (char)101, (char)51, (char)10));
		
		train.add(new SequenceElement((char)2, (char)101, (char)51, (char)10));
		train.add(new SequenceElement((char)2, (char)101, (char)51, (char)50));
		train.add(new SequenceElement((char)2, (char)101, (char)51, (char)10));
	
		train = train.refineSequence();
		assertEquals(train.size(), 4);
		
		assertEquals(train.get(0).Observation, 1);
		assertEquals(train.get(0).State, 100);
		assertEquals(train.get(0).Lac, 50);
		assertEquals(train.get(0).Repetition, 10);
		
		assertEquals(train.get(1).Observation, 1);
		assertEquals(train.get(1).State, 101);
		assertEquals(train.get(1).Lac, 50);
		assertEquals(train.get(1).Repetition, 20);
		
		assertEquals(train.get(2).Observation, 1);
		assertEquals(train.get(2).State, 101);
		assertEquals(train.get(2).Lac, 51);
		assertEquals(train.get(2).Repetition, 20);
		
		assertEquals(train.get(3).Observation, 2);
		assertEquals(train.get(3).State, 101);
		assertEquals(train.get(3).Lac, 51);
		assertEquals(train.get(3).Repetition, 70);
	}

}
